/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.unitedats.Project.Entity;


import java.io.Serializable;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

import com.unitedats.HR.Entity.HrEmployee;

/**
 *
 * @author Awad
 */
@Entity
@Table(name = "pm_project_member")
@XmlRootElement
@NamedQueries({
              @NamedQuery(name = "PmProjectMember.findAll", query = "SELECT p FROM PmProjectMember p"),
              @NamedQuery(name = "PmProjectMember.findById",
                          query = "SELECT p FROM PmProjectMember p WHERE p.id = :id"),
              @NamedQuery(name = "PmProjectMember.findByRole",
                          query = "SELECT p FROM PmProjectMember p WHERE p.role = :role")
    })
public class PmProjectMember implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "role")
    private String role;
    @JoinColumn(name = "emp_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private HrEmployee empId;
    
    
    @JoinColumn(name = "project_id", referencedColumnName = "id")
    @ManyToOne(optional = true)
    private PmProject projectId;

    public PmProjectMember() {
    }

    public PmProjectMember(Integer id) {
        this.id = id;
    }

    public PmProjectMember(Integer id, String role) {
        this.id = id;
        this.role = role;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }

    public HrEmployee getEmpId() {
        return empId;
    }

    public void setEmpId(HrEmployee empId) {
        this.empId = empId;
    }

    public PmProject getProjectId() {
        return projectId;
    }

    public void setProjectId(PmProject projectId) {
        this.projectId = projectId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PmProjectMember)) {
            return false;
        }
        PmProjectMember other = (PmProjectMember) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.unitedats.Project.Entity.PmProjectMember[ id=" + id + " ]";
    }

}
